<?php
class View_Message_Reply extends View_Message
{
	/**
	 *	...
	 *	@access		public
	 *	@return		string
	 */
	public function buildContent()
	{
		$words		= $this->words['message']['reply'];
		$messageId	= $this->request->get( 'messageId' );
		if( !$messageId )
			return;

		$message	= Logic_Message::getMessage( $messageId );
		$current	= $this->auth->getCurrentUser();
		$receiver	= Logic_User::getUserData( $message['source'] );

		$users		= Logic_User::getUsers();
		$opt_receivers	= array();
		foreach( $users as $user )
			if( $user['userId'] != $current )
				if( $user['userId'] != $data['source'] )
					$opt_receivers[$user['userId']] = $user['username'];
		if( $receivers	= $this->request->get( 'reply_receivers' ) )
			$opt_receivers['_selected']	= $receivers;

		if( !( $subject	= $this->request->get( 'reply_subject' ) ) )
			$subject	= "RE: ".$message['subject'];
		if( !( $body	= $this->request->get( 'reply_body' ) ) )
			$body		= $this->getBodyCite( $message, $words['header'] );

		//  --  COMPONENTS  --  //
		$formData	= array(
			'receiver'	=> $receiver['username'],
			'subject'	=> $subject,
			'body'		=> $body,
		);
		$ui	= array(
			'words'			=> $words,
			'form'			=> $this->buildForm(
				'message',
				'replyMessage',
				'message',
				'reply',
				$formData,
				array( 'opt_receivers' => $opt_receivers )
			),
			'buttonCancel'	=> $this->html->LinkButton(
				self::getUrl( array( 'messageId' => $messageId ) ),
				$words['buttonCancel'],
				'but cancel'
			),
			'buttonReply'	=> $this->html->Button(
				'replyMessage',
				$words['buttonReply'],
				'but edit'
			),
			'form.tag'		=> $this->html->Form(
				'replyMessage',
				self::getUrl( array( 'messageId' => $messageId, 'action' => 'reply' ) )
			),
			'colgroup'		=> $this->html->ColumnGroup( "25%", "75%" ),
			'caption'		=> $this->html->TableCaption( $words['caption'] ),
		);
		return $this->loadTemplate( 'message.reply', $ui );
	}
}
?>